package com.gopay.common.constants.gsrt;

import com.gopay.common.constants.trans.TxnStaCode;

/**
 *
 * @author ssj
 *  G商融通类型转换类
 */
public class GsrtConstants {
    /**
     * 签约类型转换
     * @param signedState
     * @return
     */
    public static String getSignedState(String signedState) {
        String typeName = "未知";
        switch (signedState) {
        case CustSignedConstants.SIGNED_STATE_01:
            typeName = "签约成功";
            break;
        case CustSignedConstants.SIGNED_STATE_02:
            typeName = "签约失败";
            break;
        case CustSignedConstants.SIGNED_STATE_03:
            typeName = "待审核";
            break;
        case CustSignedConstants.SIGNED_STATE_04:
            typeName = "签约失败";
            break;
        case CustSignedConstants.SIGNED_STATE_05:
            typeName = "用户操作中";
            break;

        default:
            break;
        }
        return typeName;
    }

    /**
     * 签约类别
     * @param signedState
     * @return
     */
    public static String getSignedType(String signedType) {
        String typeName = "未知";
        switch (signedType) {
        case CustSignedConstants.SIGNED_TYPE_01:
            typeName = "用户";
            break;
        case CustSignedConstants.SIGNED_TYPE_02:
            typeName = "担保方";
            break;
        default:
            break;
        }
        return typeName;
    }

    /**
     * 标的状态转换
     * @param signedState
     * @return
     */
    public static String getBidState(String bidState) {
        String typeName = "未知";
        switch (bidState) {
        case BidConstants.BID_STATE_RAISING:
            typeName = "募集中";
            break;
        case BidConstants.BID_STATE_REPAYING:
            typeName = "还款中";
            break;
        case BidConstants.BID_STATE_FINISHED:
            typeName = "已结束";
            break;
        default:
            break;
        }
        return typeName;
    }

    /**
     * 还款方式转换
     * @param signedState
     * @return
     */
    public static String getRepaymentType(String repaymentType) {
        String typeName = "未知";
        switch (repaymentType) {
        case RepaymentConstants.REPAYTYPE_USER:
            typeName = "用户还款";
            break;
        case RepaymentConstants.REPAYTYPE_RISK:
            typeName = "风险金还款";
            break;
        case RepaymentConstants.REPAYTYPE_SECURITY:
            typeName = "担保方还款";
            break;
        default:
            break;
        }
        return typeName;
    }

    /** 
     * 转账模式转换
     */
    public static String getAccountType(String accountType) {
        String typeName = "未知";
        switch (accountType) {
        case TransferConstants.TRANSFERMODE_RISK:
            typeName = "平台账户转风险金账户";
            break;
        case TransferConstants.TRANSFERMODE_USER:
            typeName = "平台账户转专用账户";
            break;
        case TransferConstants.TRANSFERMODE_SECURE:
            typeName = "平台账户转担保方账户";
            break;
        default:
            break;
        }
        return typeName;
    }

    /**
     * 交易码转换 gsrtweb
     * @param txnStaCd
     * @return
     */
    public static String getTxnStaCd(int txnStaCd) {
        if (txnStaCd == TxnStaCode.TXN_STA_CD_20001.value) {
            return "失败";
        } else if (txnStaCd == TxnStaCode.TXN_STA_CD_20002.value) {
            return "失败";
        } else if (txnStaCd == TxnStaCode.TXN_STA_CD_20000.value) {
            return "成功";
        } else if (txnStaCd == TxnStaCode.TXN_STA_CD_30000.value) {
            return "进行中";
        } else if (txnStaCd == TxnStaCode.TXN_STA_CD_30001.value) {
            return "用户操作中";
        } else {
            return "未知";
        }

    }

    /**
     * 翻译交易状态(只分 成功失败进行中 三种)
     * 
     * @param txnStaCd
     * @return
     */
    public static String translateTranStatus(int txnStaCd) {
        if (txnStaCd == TxnStaCode.TXN_STA_CD_20000.value) {
            return "成功";
        } else if (txnStaCd == TxnStaCode.TXN_STA_CD_90003.value) {
            return "进行中";
        } else if (txnStaCd >= TxnStaCode.TXN_STA_CD_30000.value && txnStaCd < 40000) {
            return "进行中";
        } else {
            return "失败";
        }
    }

    /** 
     * @Description: gsrtweb 查询使用 翻译账户
     * @param accountType
     * @return 
     * @author lx 
     */
    public static String transAccountTypeInfo(String accountType) {
        String type = null;
        if (CustUserTypeConstants.USER_TYPE_01.equals(accountType)) {
            type = "平台账户";
        } else if (CustUserTypeConstants.USER_TYPE_02.equals(accountType)) {
            type = "平台风险金账户";
        } else if (CustUserTypeConstants.USER_TYPE_03.equals(accountType)) {
            type = "担保方账户";
        } else {
            type = "未知";
        }

        return type;
    }

}
